using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using Admin.NET.Application.Entity;
using Admin.NET.Core;
using Furion;
using SqlSugar;

namespace Admin.NET.Application.Filter;

/// <summary>
/// 实体过滤器
/// </summary>
public class DataEntityFilter : IEntityFilter
{
	public IEnumerable<TableFilterItem<object>> AddEntityFilter()
	{
		string orgName = App.User?.FindFirst("OrgName")?.Value;
		if (string.IsNullOrWhiteSpace(orgName))
		{
			return null;
		}
		Expression<Func<Test, bool>> dynamicExpression = (Test u) => u.Name.Contains(orgName);
		TableFilterItem<object> tableFilterItem = new TableFilterItem<object>(typeof(Test), dynamicExpression);
		return new TableFilterItem<object>[1] { tableFilterItem };
	}
}
